package com.wake.mycomposebook.ui.home.modifier.m

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

/**
 *@author created by WA03675
 *@date  2022-04-18 10:44
 *@des
 */

/**
 *modifier的各种属性
 */

@Composable
fun MyModifier() {
    Column(Modifier.verticalScroll(rememberScrollState())) {
        Button(onClick = { /*TODO*/ }) {
            MyText()
        }

        Button(onClick = { /*TODO*/ }, Modifier.fillMaxWidth()) {
            MyText()
        }

        Button(
            onClick = { /*TODO*/ },
            Modifier
                .padding(12.dp)
                .fillMaxWidth()
        ) {
            MyText()
        }

        Button(
            onClick = { /*TODO*/ },
            Modifier
                .padding(12.dp)
                .size(50.dp)
                .background(
                    Color.Red,
                )
        ) {
            MyText()
        }

        Button(
            onClick = { /*TODO*/ },
            Modifier
                .width(200.dp)
                .height(100.dp)
        ) {
            MyText()
        }

        Button(
            onClick = { /*TODO*/ },
            Modifier
                .clip(RoundedCornerShape(5.dp))
                .background(Color.Red)
        ) {
            MyText()
        }

        Button(
            onClick = { /*TODO*/ },
            Modifier
                .clip(RoundedCornerShape(topEnd = 10.dp))
                .background(Color.Red)
        ) {
            MyText()
        }

        Button(onClick = { /*TODO*/ }) {
            MyText()
        }
        Button(onClick = { /*TODO*/ }, Modifier.align(Alignment.CenterHorizontally)) {
            MyText()
        }

        Button(onClick = { /*TODO*/ }, Modifier.align(Alignment.End)) {
            MyText()
        }

        Button(onClick = { /*TODO*/ }, Modifier.alpha(0.5f)) {
            MyText()
        }

        Button(onClick = { /*TODO*/ }, Modifier.shadow(10.dp)) {
            MyText()
        }
        Button(onClick = { /*TODO*/ }, Modifier.background(Color.Cyan)) {
            MyText()
        }

        MyText(modifier = Modifier.background(Brush.linearGradient(listOf(Color.Red, Color.Cyan), Offset(0f, 0f), Offset(180f, 180f))))

        MyText(modifier = Modifier.background(Brush.horizontalGradient(listOf(Color.Red, Color.Cyan))))

    }


}


@Composable
fun MyText(msg: String? = null, modifier: Modifier = Modifier) {

        Text(msg ?: "bt", style = MaterialTheme.typography.titleLarge, modifier = modifier)

}

@Composable
@Preview
fun PreviewMyModifier(){
    MyModifier()
}